Skip to content

feat: show LRCLIB lyrics in Now Playing view with caching#25

Merged
pythoninthegrass merged 1 commit intomainfrom
begin-backlog-task-296
Mar 10, 2026
Merged

feat: show LRCLIB lyrics in Now Playing view with caching#25
pythoninthegrass merged 1 commit intomainfrom
begin-backlog-task-296

Conversation

@pythoninthegrass
Copy link
Collaborator

@pythoninthegrass pythoninthegrass commented Mar 8, 2026

Summary

  • Add LRCLIB lyrics fetching with per-track SQLite caching in the Now Playing view
  • When lyrics are available, album art shrinks and a scrollable lyrics panel appears below track metadata
  • When no lyrics are found (404, instrumental, error), the view remains unchanged — no empty panels or messages
  • Negative results are cached to avoid repeated failed lookups
  • Lyrics fetch only triggers when the Now Playing view is in the foreground

Changes

Backend (Rust)

  • crates/mt-tauri/src/db/lyrics.rs — cache CRUD (get, save, clear) using existing lyrics_cache table
  • crates/mt-tauri/src/lyrics.rs — LRCLIB HTTP client (10s timeout, mt-desktop/<version> User-Agent)
  • crates/mt-tauri/src/commands/lyrics.rslyrics_get (async, cache-first) and lyrics_clear_cache Tauri commands

Frontend

  • app/frontend/js/api/lyrics.js — Tauri command wrapper
  • app/frontend/js/components/now-playing-view.js — lyrics state with visibility-gated fetching and superseded-fetch guard
  • app/frontend/views/now-playing.html — conditional two-layout rendering (with/without lyrics)

Test plan

  • 11 Rust unit tests: DB cache round-trip, negative cache, upsert, LRCLIB response parsing (200/404/instrumental)
  • 12 Vitest unit tests: API invocation, visibility gating, track change, error handling, superseded fetch
  • All 622 existing Rust tests pass
  • All 331 existing Vitest tests pass
  • Clippy clean, cargo fmt clean, deno lint/fmt clean

🤖 Generated with Claude Code

Add lyrics fetching from lrclib.net with per-track SQLite caching.
When lyrics are available, the Now Playing left panel switches to a
compact album art header with a scrollable lyrics panel below. When
no lyrics are found the view remains unchanged.

Backend: db/lyrics.rs (cache CRUD), lyrics.rs (LRCLIB HTTP client with
10s timeout, mt-desktop User-Agent), commands/lyrics.rs (lyrics_get
cache-first async command, lyrics_clear_cache). Negative results are
cached to avoid repeated failed lookups.

Frontend: api/lyrics.js (Tauri command wrapper), now-playing-view.js
(lyrics state with visibility-gated fetching, superseded-fetch guard),
now-playing.html (conditional two-layout rendering).

Tests: 11 Rust tests (DB round-trip, LRCLIB response parsing), 12
Vitest tests (API invocation, visibility gating, track change, error
handling). All 622 existing Rust + 331 Vitest tests pass.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@pythoninthegrass pythoninthegrass merged commit b7e5533 into main Mar 10, 2026
@pythoninthegrass pythoninthegrass deleted the begin-backlog-task-296 branch March 10, 2026 02:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant